/**
 * 路由
 */
 import React,{Component} from 'react';
 import {BrowserRouter,Route, Routes,Navigate} from 'react-router-dom';
 import Center from '../views/Center';
 import Cinemas from '../views/Cinemas';
 import Films from '../views/Films';
import NotFound from '../views/NotFound';
import Child from '../views/Children';
import DaiLi from '../views/反向代理';
import City from '../views/City';
import Search from '../views/Search';
function RequireAuth({ children }) {
  const authed = "true"
  return authed === 'true' ? ( // 判断 localstorage 中登录状态是否为 true
    children
  ) : (
    <Navigate to="/center" replace /> // 跳转到登录
  );
}
 class Zhuye extends Component{
   render() {
     return (  
       <div>
         <BrowserRouter>
         {this.props.children}
           <Routes>
              <Route path='/daili' element={<DaiLi />}></Route>
              <Route path='/city' element={<City />}></Route>
               <Route path='/films' element={<Films></Films>}></Route>
               {/* <Route path='/cinemas' element={<Cinemas></Cinemas>}></Route> */}
               <Route path='/cinemas' element={<RequireAuth> // 拦截组件
            <Cinemas /> // 被拦截组件
          </RequireAuth>}></Route>
          <Route path='/cinemas/search' element={<Search />}></Route>
               <Route path='/center' element={<Center></Center>}>
                 <Route path='child' element={<Child />}></Route>
               </Route>
               {/* <Redirect from="/" to="/center" /> 旧版重定向*/}
               <Route path='/' element={<Navigate to ="/center" />}  />//首页
               <Route path='*' element={<NotFound/>} /> /*404页*/
           </Routes>
           </BrowserRouter>
       </div>
     );
   };
 };
 export default Zhuye;